package com.msmall.community.bbs.preparer;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tiles.AttributeContext;
import org.apache.tiles.context.TilesRequestContext;
import org.apache.tiles.preparer.ViewPreparer;

import com.msmall.base.cache.CacheFactory;
import com.msmall.base.util.Constants;
import com.msmall.community.bbs.model.Topic;

/**
 *  获得推荐的各地小吃：按推荐时间排序的10条 constantdb.COMMEND_DISPLAY_4
 *   从BBS TOPIC 获得
 */
public class CommendFoodPreparer implements ViewPreparer{
	
	private static final Log log = LogFactory.getLog(CommendFoodPreparer.class);
	
	public void execute(TilesRequestContext tilesContext, AttributeContext context) {
		
		try{
			HttpServletRequest request = (HttpServletRequest) tilesContext.getRequest();
			List<Topic> topics = (List<Topic>) CacheFactory.getInstance().getCache(Constants.CACHE_NAME_COMMON).get(Constants.CACHE_KEY_BBS_COMMEND_INDEX_EACH_BOARD_IMAGE_LIST);
			request.setAttribute("foodcommendlist", topics);
		}catch(Exception e){
			log.debug(e);
		}
	}
}
